package com.xyd.servlet;

import com.xyd.service.impl.OrderServiceImpl;
import com.xyd.util.GetPageUtil;
import com.xyd.util.TotalPageUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/OrderGetPageServlet")
public class OrderGetPageServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        OrderServiceImpl orderService = new OrderServiceImpl();
        PrintWriter out=response.getWriter();
        int count=orderService.getCountOrder();
        int maxPage= TotalPageUtil.getTotalPage(count, GetPageUtil.PAGESiZE);
        out.print(maxPage);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
